@extends('{{ base_layout }}')

@section('{{ section_title|default('title') }}')
Edit {{ model_class }} [{{ '{{ ' }} ${{ model_name }}->id {{ '}}' }}] ::
@parent
@stop

{% if section_breadcrumb is defined %}
    @section('{{ section_breadcrumb }}')
    <li><a href="{{ '{{ ' }} route('home') {{ '}}' }}"><i class="icon-home"></i> Dashboard</a><span class="divider"><i class="icon-angle-right"></i></span></li>
    <li><a href="{{ '{{ ' }} route('{{ route_prefix }}.{{ model_name }}.index') {{ '}}' }}"><i class="icon-home"></i> {{ model_class }} list</a><span class="divider"><i class="icon-angle-right"></i></span></li>
    <li class="active">Edit {{ model_class }} [{{ '{{ ' }} ${{ model_name }}->id {{ '}}' }}] </li>
    @stop
{% endif %}

@section('{{ section_content|default('content') }}')

<p>{{ '{{ ' }}link_to_route('{{ route_prefix }}.{{ model_name }}.index', 'Back to {{ model_class}} list', null, array('class' => 'btn btn-info')) {{ '}}' }}</p>

<div class="row-fluid">
    {{ '{{ ' }}Form::open(array('route' => array('{{ route_prefix }}.{{ model_name }}.edit', ${{ model_name }}->id), 'class' => 'form-horizontal')) {{ '}}' }}

{% for field, definition in fields if definition.autoincrement is not defined %}
    <div  class="control-group {{ '{{' }} $errors->first('{{ field }}', ' error') {{ '}}' }}">
        <label class="control-label" for="{{ field }}">{{ field|replace('_', ' ')|title }}</label>
        <div class="controls">
            <input class="" placeholder="{{ field|replace('_', ' ')|title }}" title="{{ field|replace('_', ' ')|title }}" name="{{ field }}" type="text" value="{{ '{{' }} Input::old('{{ field }}', ${{ model_name }}->{{ field }}) {{ '}}' }}">
            {{ '{{' }} $errors->first('{{ field }}', '<span class="help-inline">:message</span>') {{ '}}' }}
        </div>
    </div>
{% endfor %}

{% if relations.belongsTo is defined %}
{% for related in relations.belongsTo %}
    <div class="control-group {{ '{{' }} $errors->first('{{ related }}_id', ' error') {{ '}}' }}">
        <label class="control-label">{{ related|replace('_', ' ')|title }}</label>
        <div class="controls">
            {{ '{{' }} Form::select('{{ related }}_id', ${{ related }}_list, Input::old('{{ related }}_id', ${{ model_name }}->{{ related }}_id), array('data-placeholder' => '{{ related|replace('_', ' ')|title }}', 'class' => 'chosen span6', 'name' => '{{ related }}_id')) {{ '}}' }}
            {{ '{{' }} $errors->first('{{ related }}_id', '<span class="help-inline">:message</span>') {{ '}}' }}
        </div>
    </div>
{% endfor %}
{% endif %}

    <div class="form-actions">
        {{ '{{ ' }} Form::submit('Submit', array('class' => 'btn btn-info')) {{ '}}' }} &nbsp;&nbsp;
        {{ '{{ ' }} link_to_route('{{ route_prefix }}.{{ model_name }}.index', 'Cancel', null, array('class' => 'btn ')) {{ '}}' }}
    </div>
    {{ '{{ ' }} Form::close() {{ '}}' }}
@stop